/*
Copyright (C) 2013 Matthew Netsch

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef PASSGEN_H
#define PASSGEN_H

#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QCheckBox>
#include <QLabel>
#include <QLineEdit>

class PassGen : public QDialog
{
    Q_OBJECT
public:
    explicit PassGen(QWidget *parent = 0);
    PassGen::~PassGen();

    int  getSize();
    void generate(char *result);

    bool getShowPass();

signals:
    void passShowed(bool show);
    
public slots:
    void commit();

private:
    typedef enum
    {
        NONE    = 0x0000,
        LETTER  = 0x0001,
        UPPER   = 0x0002,
        NUMBER  = 0x0004,
        SPECIAL = 0x0008,
        LAST    = 0x0010
    } chartype;

    int  maxlength;
    int  enables;
    int  num_enables;
    bool show_pass;

    int getNextIndex(chartype *passtype);
    void initState();

    //Layout
    QVBoxLayout *top;
    QHBoxLayout *buttons;
    QVBoxLayout *options;

    QPushButton *OK;
    QPushButton *cancel;

    QCheckBox   *showPass;
    QCheckBox   *useLetters;
    QCheckBox   *useUpper;
    QCheckBox   *useNumbers;
    QCheckBox   *useSpecial;

    QLabel      *maxLabel;
    QLineEdit   *maxEdit;

};

#endif // PASSGEN_H
